package org.jing.ext.media.m3u8;

import org.jing.core.lang.itf.JEnum;
import org.jing.core.util.GenericUtil;
import org.jing.ext.media.m3u8.tag.M3U8AllowCache;
import org.jing.ext.media.m3u8.tag.M3U8Begin;
import org.jing.ext.media.m3u8.tag.M3U8End;
import org.jing.ext.media.m3u8.tag.M3U8Key;
import org.jing.ext.media.m3u8.tag.M3U8MediaPartition;
import org.jing.ext.media.m3u8.tag.M3U8MediaSequence;
import org.jing.ext.media.m3u8.tag.M3U8PlaylistType;
import org.jing.ext.media.m3u8.tag.M3U8TargetDuration;
import org.jing.ext.media.m3u8.tag.M3U8Version;

/**
 * Description: <br>
 *
 * @author bksmate <br>
 * @since 2024-12-24 <br>
 */
public enum M3U8TagType implements JEnum<String> {
    EXT_BEGIN("EXTM3U", M3U8Begin.class),
    EXT_X_VERSION("EXT-X-VERSION", M3U8Version.class),
    EXT_X_ALLOW_CACHE("EXT-X-ALLOW-CACHE", M3U8AllowCache.class),
    EXT_X_TARGETDURATION("EXT-X-TARGETDURATION", M3U8TargetDuration.class),
    EXT_X_MEDIA_SEQUENCE("EXT-X-MEDIA-SEQUENCE", M3U8MediaSequence.class),
    EXT_X_PLAYLIST_TYPE("EXT-X-PLAYLIST-TYPE", M3U8PlaylistType.class),
    EXT_X_KEY("EXT-X-KEY", M3U8Key.class),
    EXT_INFO("EXTINF", M3U8MediaPartition.class),
    EXT_END("EXT-X-ENDLIST", M3U8End.class)
    ;

    private final String tagName;

    private final Class<? extends BaseM3U8Tag> tagClass;

    M3U8TagType(String tagName, Class<? extends BaseM3U8Tag> tagClass) {
        this.tagName = tagName;
        this.tagClass = tagClass;
    }

    public String getTagName() {
        return tagName;
    }

    public Class<? extends BaseM3U8Tag> getTagClass() {
        return tagClass;
    }

    @Override public boolean equalsByType(Object... objects) {
        return GenericUtil.count(objects) > 0  && objects[0] instanceof String && getTagName().equalsIgnoreCase(((String) objects[0]));
    }

    @Override public String output() {
        return getTagName();
    }
}
